let wsURL = "";
import baseURL from "./baseURL";
function formatWebSocketUrl(url) {
  const suffix = url.slice(-1);
  if (suffix == "/") {
    return url.slice(0, -1);
  } else {
    return url;
  }
}

if (process.env.NODE_ENV !== "production") {
  if (baseURL.includes("stake")) {
    wsURL = formatWebSocketUrl(`${baseURL}`).replace("http", "ws") + ":8076";
  } else {
    wsURL = formatWebSocketUrl(`${baseURL}`)
      .replace("api.", "gw.") 
      .replace("https", "wss");
  }
} else {
  if (baseURL.includes("stake")) {
    wsURL = formatWebSocketUrl(`${baseURL}`).replace("http", "ws") + ":8076";
  } else {
    wsURL = formatWebSocketUrl(`${baseURL}`)
      .replace("api.", "gw.")
      .replace("https", "wss");
  }
}

console.log("wsURL", wsURL);

export default wsURL;
